﻿/*
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

namespace SharpMixLib
{
    /// <summary>
    /// 
    /// </summary>
    public class Instruction
    {
        /// <summary>
        /// 
        /// </summary>
        private int opcode = 0;

        /// <summary>
        /// 
        /// </summary>
        private int fieldcode = 0;

        /// <summary>
        /// 
        /// </summary>
        private int adress = 0;

        /// <summary>
        /// 
        /// </summary>
        private int index = 0;

        /// <summary>
        /// 
        /// </summary>
        public int OpCode
        {
            get
            {
                return opcode;
            }
            set
            {
                opcode = value;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        public int FieldCode
        {
            get
            {
                return fieldcode;
            }
            set
            {
                fieldcode = value;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        public int Adress
        {
            get
            {
                return adress;
            }
            set
            {
                adress = value;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        public int IndexSpecification
        {
            get
            {
                return index;
            }
            set
            {
                index = value;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="word"></param>
        public void ConvertFromWord(Word word)
        {
            /// (5:5)
            OpCode = word.GetWordByField(45).GetTotalValue();
            /// (4:4)
            FieldCode = word.GetWordByField(36).GetTotalValue();
            /// (3:3)
            IndexSpecification = word.GetWordByField(27).GetTotalValue();
            /// (1:2)
            Adress = word.GetWordByField(10).GetTotalValue();
        }
    }
}
